#include<Servo.h>
#include<IRremote.h>
Servo myservo;
int ledPin = 10;
int RECV_PIN = 11;
boolean ledState = LOW;
IRrecv irrecv(RECV_PIN);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(ledPin,OUTPUT);
  myservo.attach(7);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(irrecv.decode()){
    Serial.println(irrecv.decodedIRData.decodedRawData,HEX);
    ActServo(irrecv.decodedIRData.decodedRawData);
    irrecv.resume();
  }
}
void ActServo(long RawData){
  int angle1 = 0;
  int angle[12] = {};
  for(int i=0;i<12;i++){
    angle[i] = angle1;
    angle1 += 15;
  }
  long command[12] = {
    0xE916FF00 , 0xE619FF00 , 0xF20Dff00 , 0xF30CFF00 , 
    0xE718FF00 , 0xA15EFF00 , 0xF708FF00 , 0xE31CFF00 , 
    0xA55AFF00 , 0xBD42FF00 , 0xAD52FF00 , 0xB54AFF00 
  };
  if(RawData == 0xBC43FF00){
    ledState = !ledState;
    digitalWrite(ledPin,ledState);
  }
  for(int i=0;i<12;i++){
    if(RawData == command[i]){
      myservo.write(angle[i]);
    }
  }
}
